package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.SupplierDAOInterface;
import org.cuatrovientos.erp.model.Supplier;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Holds all the business logic for Supplier related management
 * @author VB
 */
public class SupplierBO implements SupplierBOInterface {
	
	// Get log4j logger
	private static final Logger logger = Logger.getLogger(SupplierBO.class);
	
	@Autowired
    private SupplierDAOInterface supplierDAO;

	@Override
	public Supplier selectById(int id) {
		logger.info("selectById: " + id);
		return supplierDAO.selectById(id);
	}

	@Override
	public List<Supplier> selectAll() {
		logger.info("selectAll: ");
		return supplierDAO.selectAll();
	}

	@Override
	public List<Supplier> search(String name) {
		logger.info("search : " + name);
		return supplierDAO.search(name);
	}

	@Override
	public void deleteById(int id) {
		logger.info("delete: " + id);
		supplierDAO.deleteById(id);
	}

	@Override
	public void insert(Supplier supplier) {
		logger.info("insert: " + supplier);
		supplierDAO.insert(supplier);
	}

	@Override
	public void update(Supplier supplier) {
		logger.info("update: " + supplier);
		supplierDAO.update(supplier);
	}
	
	public void delete(Supplier supplier){
		logger.info("delete: " + supplier);
		supplierDAO.delete(supplier);
	}
}
